(function()
{
 "use strict";
 /*
   hook up event handlers 
 */
 function register_event_handlers()
 {
     
        $("#homebtn").click(function(evt)
        {
         activate_subpage("#mainsub"); 
        });
        
        $("#messagebtn").click(function(evt)
        {
         activate_subpage("#messages_page"); 
        });
        $("#profilebtn").click(function(evt)
        {
         activate_subpage("#profile_page"); 
        });
        $(document).on("click", "#favbtn", function(evt)
        {
         activate_subpage("#profile_page"); 
        }); 
         
        
       $("form#form_join").submit(function(e){ 
        /* your code goes here */ 
            e.preventDefault();

                $.ajax({
                    type: "POST",
                    url: "http://localhost/wnsgbl-repo/newsletter/newsletter_subscribe_action",
                    data: $("#form_join").serialize(),
                    success: function(data)
                    {
						  var jsonData = JSON.parse(data);   
							if(jsonData == 'already'){
							  
								activate_subpage("#failed_join"); 
							}else{ 
						 
								activate_subpage("#success_join"); 
							}
						  
                    }
                });

                return false;
        });
     
         
}
 $(document).ready(register_event_handlers);
})();
